
_cat:     file format elf32-i386


Disassembly of section .text:

00000000 <main>:
  }
}

int
main(int argc, char *argv[])
{
   0:	55                   	push   %ebp
   1:	89 e5                	mov    %esp,%ebp
   3:	57                   	push   %edi
   4:	56                   	push   %esi
    exit();
  }
}

int
main(int argc, char *argv[])
   5:	be 01 00 00 00       	mov    $0x1,%esi
{
   a:	53                   	push   %ebx
   b:	83 e4 f0             	and    $0xfffffff0,%esp
   e:	83 ec 20             	sub    $0x20,%esp
  11:	8b 7d 08             	mov    0x8(%ebp),%edi
    exit();
  }
}

int
main(int argc, char *argv[])
  14:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  17:	83 c3 04             	add    $0x4,%ebx
{
  int fd, i;

  if(argc <= 1){
  1a:	83 ff 01             	cmp    $0x1,%edi
  1d:	7e 5d                	jle    7c <main+0x7c>
  1f:	90                   	nop
    cat(0);
    exit();
  }

  for(i = 1; i < argc; i++){
    if((fd = open(argv[i], 0)) < 0){
  20:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  27:	00 
  28:	8b 03                	mov    (%ebx),%eax
  2a:	89 04 24             	mov    %eax,(%esp)
  2d:	e8 72 03 00 00       	call   3a4 <open>
  32:	85 c0                	test   %eax,%eax
  34:	78 27                	js     5d <main+0x5d>
      printf(1, "cat: cannot open %s\n", argv[i]);
      exit();
    }
    cat(fd);
  36:	89 04 24             	mov    %eax,(%esp)
  if(argc <= 1){
    cat(0);
    exit();
  }

  for(i = 1; i < argc; i++){
  39:	83 c6 01             	add    $0x1,%esi
  3c:	83 c3 04             	add    $0x4,%ebx
    if((fd = open(argv[i], 0)) < 0){
      printf(1, "cat: cannot open %s\n", argv[i]);
      exit();
    }
    cat(fd);
  3f:	89 44 24 1c          	mov    %eax,0x1c(%esp)
  43:	e8 48 00 00 00       	call   90 <cat>
    close(fd);
  48:	8b 44 24 1c          	mov    0x1c(%esp),%eax
  4c:	89 04 24             	mov    %eax,(%esp)
  4f:	e8 38 03 00 00       	call   38c <close>
  if(argc <= 1){
    cat(0);
    exit();
  }

  for(i = 1; i < argc; i++){
  54:	39 fe                	cmp    %edi,%esi
  56:	75 c8                	jne    20 <main+0x20>
      exit();
    }
    cat(fd);
    close(fd);
  }
  exit();
  58:	e8 07 03 00 00       	call   364 <exit>
    exit();
  }

  for(i = 1; i < argc; i++){
    if((fd = open(argv[i], 0)) < 0){
      printf(1, "cat: cannot open %s\n", argv[i]);
  5d:	8b 03                	mov    (%ebx),%eax
  5f:	c7 44 24 04 87 07 00 	movl   $0x787,0x4(%esp)
  66:	00 
  67:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  6e:	89 44 24 08          	mov    %eax,0x8(%esp)
  72:	e8 39 04 00 00       	call   4b0 <printf>
      exit();
  77:	e8 e8 02 00 00       	call   364 <exit>
main(int argc, char *argv[])
{
  int fd, i;

  if(argc <= 1){
    cat(0);
  7c:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  83:	e8 08 00 00 00       	call   90 <cat>
    exit();
  88:	e8 d7 02 00 00       	call   364 <exit>
  8d:	90                   	nop
  8e:	90                   	nop
  8f:	90                   	nop

00000090 <cat>:

char buf[512];

void
cat(int fd)
{
  90:	53                   	push   %ebx
  91:	83 ec 18             	sub    $0x18,%esp
  94:	8b 5c 24 20          	mov    0x20(%esp),%ebx
  int n;

  while((n = read(fd, buf, sizeof(buf))) > 0)
  98:	eb 1e                	jmp    b8 <cat+0x28>
  9a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    write(1, buf, n);
  a0:	89 44 24 08          	mov    %eax,0x8(%esp)
  a4:	c7 44 24 04 a0 0a 00 	movl   $0xaa0,0x4(%esp)
  ab:	00 
  ac:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  b3:	e8 cc 02 00 00       	call   384 <write>
void
cat(int fd)
{
  int n;

  while((n = read(fd, buf, sizeof(buf))) > 0)
  b8:	c7 44 24 08 00 02 00 	movl   $0x200,0x8(%esp)
  bf:	00 
  c0:	c7 44 24 04 a0 0a 00 	movl   $0xaa0,0x4(%esp)
  c7:	00 
  c8:	89 1c 24             	mov    %ebx,(%esp)
  cb:	e8 ac 02 00 00       	call   37c <read>
  d0:	83 f8 00             	cmp    $0x0,%eax
  d3:	7f cb                	jg     a0 <cat+0x10>
    write(1, buf, n);
  if(n < 0){
  d5:	75 05                	jne    dc <cat+0x4c>
    printf(1, "cat: read error\n");
    exit();
  }
}
  d7:	83 c4 18             	add    $0x18,%esp
  da:	5b                   	pop    %ebx
  db:	c3                   	ret    
  int n;

  while((n = read(fd, buf, sizeof(buf))) > 0)
    write(1, buf, n);
  if(n < 0){
    printf(1, "cat: read error\n");
  dc:	c7 44 24 04 76 07 00 	movl   $0x776,0x4(%esp)
  e3:	00 
  e4:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  eb:	e8 c0 03 00 00       	call   4b0 <printf>
    exit();
  f0:	e8 6f 02 00 00       	call   364 <exit>
  f5:	90                   	nop
  f6:	90                   	nop
  f7:	90                   	nop
  f8:	90                   	nop
  f9:	90                   	nop
  fa:	90                   	nop
  fb:	90                   	nop
  fc:	90                   	nop
  fd:	90                   	nop
  fe:	90                   	nop
  ff:	90                   	nop

00000100 <strcpy>:
#include "user.h"
#include "x86.h"

char*
strcpy(char *s, char *t)
{
 100:	53                   	push   %ebx
 101:	8b 44 24 08          	mov    0x8(%esp),%eax
  char *os;

  os = s;
  while((*s++ = *t++) != 0)
 105:	31 d2                	xor    %edx,%edx
#include "user.h"
#include "x86.h"

char*
strcpy(char *s, char *t)
{
 107:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
 10b:	90                   	nop
 10c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  char *os;

  os = s;
  while((*s++ = *t++) != 0)
 110:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
 114:	88 0c 10             	mov    %cl,(%eax,%edx,1)
 117:	83 c2 01             	add    $0x1,%edx
 11a:	84 c9                	test   %cl,%cl
 11c:	75 f2                	jne    110 <strcpy+0x10>
    ;
  return os;
}
 11e:	5b                   	pop    %ebx
 11f:	c3                   	ret    

00000120 <strcmp>:

int
strcmp(const char *p, const char *q)
{
 120:	56                   	push   %esi
 121:	53                   	push   %ebx
 122:	8b 4c 24 0c          	mov    0xc(%esp),%ecx
 126:	8b 54 24 10          	mov    0x10(%esp),%edx
  while(*p && *p == *q)
 12a:	0f b6 01             	movzbl (%ecx),%eax
 12d:	0f b6 1a             	movzbl (%edx),%ebx
 130:	84 c0                	test   %al,%al
 132:	74 24                	je     158 <strcmp+0x38>
 134:	38 d8                	cmp    %bl,%al
 136:	74 11                	je     149 <strcmp+0x29>
 138:	eb 2e                	jmp    168 <strcmp+0x48>
 13a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
 140:	83 c1 01             	add    $0x1,%ecx
 143:	38 d8                	cmp    %bl,%al
 145:	75 21                	jne    168 <strcmp+0x48>
    p++, q++;
 147:	89 f2                	mov    %esi,%edx
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
 149:	0f b6 41 01          	movzbl 0x1(%ecx),%eax
    p++, q++;
 14d:	8d 72 01             	lea    0x1(%edx),%esi
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
 150:	0f b6 5a 01          	movzbl 0x1(%edx),%ebx
 154:	84 c0                	test   %al,%al
 156:	75 e8                	jne    140 <strcmp+0x20>
    p++, q++;
  return (uchar)*p - (uchar)*q;
 158:	0f b6 db             	movzbl %bl,%ebx
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
 15b:	31 c0                	xor    %eax,%eax
    p++, q++;
  return (uchar)*p - (uchar)*q;
 15d:	29 d8                	sub    %ebx,%eax
}
 15f:	5b                   	pop    %ebx
 160:	5e                   	pop    %esi
 161:	c3                   	ret    
 162:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
    p++, q++;
  return (uchar)*p - (uchar)*q;
 168:	0f b6 db             	movzbl %bl,%ebx
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
 16b:	0f b6 c0             	movzbl %al,%eax
    p++, q++;
  return (uchar)*p - (uchar)*q;
 16e:	29 d8                	sub    %ebx,%eax
}
 170:	5b                   	pop    %ebx
 171:	5e                   	pop    %esi
 172:	c3                   	ret    
 173:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
 179:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000180 <strlen>:

uint
strlen(char *s)
{
 180:	8b 4c 24 04          	mov    0x4(%esp),%ecx
  int n;

  for(n = 0; s[n]; n++)
 184:	31 c0                	xor    %eax,%eax
 186:	80 39 00             	cmpb   $0x0,(%ecx)
 189:	74 10                	je     19b <strlen+0x1b>
 18b:	31 d2                	xor    %edx,%edx
 18d:	8d 76 00             	lea    0x0(%esi),%esi
 190:	83 c2 01             	add    $0x1,%edx
 193:	80 3c 11 00          	cmpb   $0x0,(%ecx,%edx,1)
 197:	89 d0                	mov    %edx,%eax
 199:	75 f5                	jne    190 <strlen+0x10>
    ;
  return n;
}
 19b:	f3 c3                	repz ret 
 19d:	8d 76 00             	lea    0x0(%esi),%esi

000001a0 <memset>:

void*
memset(void *dst, int c, uint n)
{
 1a0:	57                   	push   %edi
 1a1:	8b 54 24 08          	mov    0x8(%esp),%edx
}

static inline void
stosb(void *addr, int data, int cnt)
{
  asm volatile("cld; rep stosb" :
 1a5:	8b 4c 24 10          	mov    0x10(%esp),%ecx
 1a9:	8b 44 24 0c          	mov    0xc(%esp),%eax
 1ad:	89 d7                	mov    %edx,%edi
 1af:	fc                   	cld    
 1b0:	f3 aa                	rep stos %al,%es:(%edi)
  stosb(dst, c, n);
  return dst;
}
 1b2:	89 d0                	mov    %edx,%eax
 1b4:	5f                   	pop    %edi
 1b5:	c3                   	ret    
 1b6:	8d 76 00             	lea    0x0(%esi),%esi
 1b9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

000001c0 <strchr>:

char*
strchr(const char *s, char c)
{
 1c0:	8b 44 24 04          	mov    0x4(%esp),%eax
 1c4:	0f b6 4c 24 08       	movzbl 0x8(%esp),%ecx
  for(; *s; s++)
 1c9:	0f b6 10             	movzbl (%eax),%edx
 1cc:	84 d2                	test   %dl,%dl
 1ce:	74 1d                	je     1ed <strchr+0x2d>
    if(*s == c)
 1d0:	38 ca                	cmp    %cl,%dl
 1d2:	75 0e                	jne    1e2 <strchr+0x22>
 1d4:	eb 1c                	jmp    1f2 <strchr+0x32>
 1d6:	66 90                	xchg   %ax,%ax
}

char*
strchr(const char *s, char c)
{
  for(; *s; s++)
 1d8:	83 c0 01             	add    $0x1,%eax
    if(*s == c)
 1db:	38 ca                	cmp    %cl,%dl
 1dd:	8d 76 00             	lea    0x0(%esi),%esi
 1e0:	74 0e                	je     1f0 <strchr+0x30>
}

char*
strchr(const char *s, char c)
{
  for(; *s; s++)
 1e2:	0f b6 50 01          	movzbl 0x1(%eax),%edx
 1e6:	84 d2                	test   %dl,%dl
 1e8:	75 ee                	jne    1d8 <strchr+0x18>
    if(*s == c)
      return (char*) s;
  return 0;
 1ea:	31 c0                	xor    %eax,%eax
 1ec:	c3                   	ret    
 1ed:	31 c0                	xor    %eax,%eax
 1ef:	90                   	nop
}
 1f0:	f3 c3                	repz ret 
 1f2:	f3 c3                	repz ret 
 1f4:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
 1fa:	8d bf 00 00 00 00    	lea    0x0(%edi),%edi

00000200 <gets>:

char*
gets(char *buf, int max)
{
 200:	55                   	push   %ebp
 201:	57                   	push   %edi
 202:	56                   	push   %esi
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 203:	31 f6                	xor    %esi,%esi
  return 0;
}

char*
gets(char *buf, int max)
{
 205:	53                   	push   %ebx
 206:	83 ec 2c             	sub    $0x2c,%esp
 209:	8b 7c 24 40          	mov    0x40(%esp),%edi
 20d:	8b 6c 24 44          	mov    0x44(%esp),%ebp
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 211:	eb 38                	jmp    24b <gets+0x4b>
 213:	90                   	nop
 214:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    cc = read(0, &c, 1);
 218:	8d 44 24 1f          	lea    0x1f(%esp),%eax
 21c:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
 223:	00 
 224:	89 44 24 04          	mov    %eax,0x4(%esp)
 228:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
 22f:	e8 48 01 00 00       	call   37c <read>
    if(cc < 1)
 234:	85 c0                	test   %eax,%eax
 236:	7e 1a                	jle    252 <gets+0x52>
      break;
    buf[i++] = c;
 238:	0f b6 44 24 1f       	movzbl 0x1f(%esp),%eax
gets(char *buf, int max)
{
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 23d:	89 de                	mov    %ebx,%esi
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
    buf[i++] = c;
    if(c == '\n' || c == '\r')
 23f:	3c 0d                	cmp    $0xd,%al

  for(i=0; i+1 < max; ){
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
    buf[i++] = c;
 241:	88 44 1f ff          	mov    %al,-0x1(%edi,%ebx,1)
    if(c == '\n' || c == '\r')
 245:	74 0b                	je     252 <gets+0x52>
 247:	3c 0a                	cmp    $0xa,%al
 249:	74 07                	je     252 <gets+0x52>
gets(char *buf, int max)
{
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 24b:	8d 5e 01             	lea    0x1(%esi),%ebx
 24e:	39 eb                	cmp    %ebp,%ebx
 250:	7c c6                	jl     218 <gets+0x18>
      break;
    buf[i++] = c;
    if(c == '\n' || c == '\r')
      break;
  }
  buf[i] = '\0';
 252:	c6 04 37 00          	movb   $0x0,(%edi,%esi,1)
  return buf;
}
 256:	83 c4 2c             	add    $0x2c,%esp
 259:	89 f8                	mov    %edi,%eax
 25b:	5b                   	pop    %ebx
 25c:	5e                   	pop    %esi
 25d:	5f                   	pop    %edi
 25e:	5d                   	pop    %ebp
 25f:	c3                   	ret    

00000260 <stat>:

int
stat(char *n, struct statt *st)
{
 260:	83 ec 1c             	sub    $0x1c,%esp
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 263:	8b 44 24 20          	mov    0x20(%esp),%eax
  return buf;
}

int
stat(char *n, struct statt *st)
{
 267:	89 5c 24 14          	mov    %ebx,0x14(%esp)
 26b:	89 74 24 18          	mov    %esi,0x18(%esp)
  int fd;
  int r;

  fd = open(n, O_RDONLY);
  if(fd < 0)
    return -1;
 26f:	be ff ff ff ff       	mov    $0xffffffff,%esi
stat(char *n, struct statt *st)
{
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 274:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
 27b:	00 
 27c:	89 04 24             	mov    %eax,(%esp)
 27f:	e8 20 01 00 00       	call   3a4 <open>
  if(fd < 0)
 284:	85 c0                	test   %eax,%eax
stat(char *n, struct statt *st)
{
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 286:	89 c3                	mov    %eax,%ebx
  if(fd < 0)
 288:	78 1a                	js     2a4 <stat+0x44>
    return -1;
  r = fstat(fd, st);
 28a:	8b 44 24 24          	mov    0x24(%esp),%eax
 28e:	89 1c 24             	mov    %ebx,(%esp)
 291:	89 44 24 04          	mov    %eax,0x4(%esp)
 295:	e8 22 01 00 00       	call   3bc <fstat>
  close(fd);
 29a:	89 1c 24             	mov    %ebx,(%esp)
  int r;

  fd = open(n, O_RDONLY);
  if(fd < 0)
    return -1;
  r = fstat(fd, st);
 29d:	89 c6                	mov    %eax,%esi
  close(fd);
 29f:	e8 e8 00 00 00       	call   38c <close>
  return r;
}
 2a4:	89 f0                	mov    %esi,%eax
 2a6:	8b 5c 24 14          	mov    0x14(%esp),%ebx
 2aa:	8b 74 24 18          	mov    0x18(%esp),%esi
 2ae:	83 c4 1c             	add    $0x1c,%esp
 2b1:	c3                   	ret    
 2b2:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 2b9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

000002c0 <atoi>:

int
atoi(const char *s)
{
 2c0:	53                   	push   %ebx
 2c1:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  int n;

  n = 0;
 2c5:	31 c0                	xor    %eax,%eax
  while('0' <= *s && *s <= '9')
 2c7:	0f b6 11             	movzbl (%ecx),%edx
 2ca:	8d 5a d0             	lea    -0x30(%edx),%ebx
 2cd:	80 fb 09             	cmp    $0x9,%bl
 2d0:	77 1e                	ja     2f0 <atoi+0x30>
 2d2:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    n = n*10 + *s++ - '0';
 2d8:	0f be d2             	movsbl %dl,%edx
 2db:	83 c1 01             	add    $0x1,%ecx
 2de:	8d 04 80             	lea    (%eax,%eax,4),%eax
 2e1:	8d 44 42 d0          	lea    -0x30(%edx,%eax,2),%eax
atoi(const char *s)
{
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
 2e5:	0f b6 11             	movzbl (%ecx),%edx
 2e8:	8d 5a d0             	lea    -0x30(%edx),%ebx
 2eb:	80 fb 09             	cmp    $0x9,%bl
 2ee:	76 e8                	jbe    2d8 <atoi+0x18>
    n = n*10 + *s++ - '0';
  return n;
}
 2f0:	5b                   	pop    %ebx
 2f1:	c3                   	ret    
 2f2:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 2f9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000300 <memmove>:

void*
memmove(void *vdst, void *vsrc, int n)
{
 300:	56                   	push   %esi
 301:	53                   	push   %ebx
 302:	8b 5c 24 14          	mov    0x14(%esp),%ebx
 306:	8b 44 24 0c          	mov    0xc(%esp),%eax
 30a:	8b 74 24 10          	mov    0x10(%esp),%esi
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
 30e:	85 db                	test   %ebx,%ebx
 310:	7e 14                	jle    326 <memmove+0x26>
    n = n*10 + *s++ - '0';
  return n;
}

void*
memmove(void *vdst, void *vsrc, int n)
 312:	31 d2                	xor    %edx,%edx
 314:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
    *dst++ = *src++;
 318:	0f b6 0c 16          	movzbl (%esi,%edx,1),%ecx
 31c:	88 0c 10             	mov    %cl,(%eax,%edx,1)
 31f:	83 c2 01             	add    $0x1,%edx
{
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
 322:	39 da                	cmp    %ebx,%edx
 324:	75 f2                	jne    318 <memmove+0x18>
    *dst++ = *src++;
  return vdst;
}
 326:	5b                   	pop    %ebx
 327:	5e                   	pop    %esi
 328:	c3                   	ret    
 329:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00000330 <memcpy>:

void *
memcpy(void *dst, const void *src, uint n)
{
 330:	56                   	push   %esi
 331:	53                   	push   %ebx
 332:	8b 5c 24 14          	mov    0x14(%esp),%ebx
 336:	8b 44 24 0c          	mov    0xc(%esp),%eax
 33a:	8b 74 24 10          	mov    0x10(%esp),%esi
{
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
 33e:	85 db                	test   %ebx,%ebx
 340:	7e 14                	jle    356 <memcpy+0x26>
 342:	31 d2                	xor    %edx,%edx
 344:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    *dst++ = *src++;
 348:	0f b6 0c 16          	movzbl (%esi,%edx,1),%ecx
 34c:	88 0c 10             	mov    %cl,(%eax,%edx,1)
 34f:	83 c2 01             	add    $0x1,%edx
{
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
 352:	39 da                	cmp    %ebx,%edx
 354:	75 f2                	jne    348 <memcpy+0x18>

void *
memcpy(void *dst, const void *src, uint n)
{
  return memmove(dst, src, n);
}
 356:	5b                   	pop    %ebx
 357:	5e                   	pop    %esi
 358:	c3                   	ret    
 359:	90                   	nop
 35a:	90                   	nop
 35b:	90                   	nop

0000035c <fork>:
 35c:	b8 01 00 00 00       	mov    $0x1,%eax
 361:	cd 40                	int    $0x40
 363:	c3                   	ret    

00000364 <exit>:
 364:	b8 02 00 00 00       	mov    $0x2,%eax
 369:	cd 40                	int    $0x40
 36b:	c3                   	ret    

0000036c <wait>:
 36c:	b8 03 00 00 00       	mov    $0x3,%eax
 371:	cd 40                	int    $0x40
 373:	c3                   	ret    

00000374 <pipe>:
 374:	b8 04 00 00 00       	mov    $0x4,%eax
 379:	cd 40                	int    $0x40
 37b:	c3                   	ret    

0000037c <read>:
 37c:	b8 06 00 00 00       	mov    $0x6,%eax
 381:	cd 40                	int    $0x40
 383:	c3                   	ret    

00000384 <write>:
 384:	b8 05 00 00 00       	mov    $0x5,%eax
 389:	cd 40                	int    $0x40
 38b:	c3                   	ret    

0000038c <close>:
 38c:	b8 07 00 00 00       	mov    $0x7,%eax
 391:	cd 40                	int    $0x40
 393:	c3                   	ret    

00000394 <kill>:
 394:	b8 08 00 00 00       	mov    $0x8,%eax
 399:	cd 40                	int    $0x40
 39b:	c3                   	ret    

0000039c <exec>:
 39c:	b8 09 00 00 00       	mov    $0x9,%eax
 3a1:	cd 40                	int    $0x40
 3a3:	c3                   	ret    

000003a4 <open>:
 3a4:	b8 0a 00 00 00       	mov    $0xa,%eax
 3a9:	cd 40                	int    $0x40
 3ab:	c3                   	ret    

000003ac <mknod>:
 3ac:	b8 0b 00 00 00       	mov    $0xb,%eax
 3b1:	cd 40                	int    $0x40
 3b3:	c3                   	ret    

000003b4 <unlink>:
 3b4:	b8 0c 00 00 00       	mov    $0xc,%eax
 3b9:	cd 40                	int    $0x40
 3bb:	c3                   	ret    

000003bc <fstat>:
 3bc:	b8 0d 00 00 00       	mov    $0xd,%eax
 3c1:	cd 40                	int    $0x40
 3c3:	c3                   	ret    

000003c4 <link>:
 3c4:	b8 0e 00 00 00       	mov    $0xe,%eax
 3c9:	cd 40                	int    $0x40
 3cb:	c3                   	ret    

000003cc <mkdir>:
 3cc:	b8 0f 00 00 00       	mov    $0xf,%eax
 3d1:	cd 40                	int    $0x40
 3d3:	c3                   	ret    

000003d4 <chdir>:
 3d4:	b8 10 00 00 00       	mov    $0x10,%eax
 3d9:	cd 40                	int    $0x40
 3db:	c3                   	ret    

000003dc <dup>:
 3dc:	b8 11 00 00 00       	mov    $0x11,%eax
 3e1:	cd 40                	int    $0x40
 3e3:	c3                   	ret    

000003e4 <getpid>:
 3e4:	b8 12 00 00 00       	mov    $0x12,%eax
 3e9:	cd 40                	int    $0x40
 3eb:	c3                   	ret    

000003ec <sbrk>:
 3ec:	b8 13 00 00 00       	mov    $0x13,%eax
 3f1:	cd 40                	int    $0x40
 3f3:	c3                   	ret    

000003f4 <sleep>:
 3f4:	b8 14 00 00 00       	mov    $0x14,%eax
 3f9:	cd 40                	int    $0x40
 3fb:	c3                   	ret    
 3fc:	90                   	nop
 3fd:	90                   	nop
 3fe:	90                   	nop
 3ff:	90                   	nop

00000400 <putc>:
#include "stat.h"
#include "user.h"

static void
putc(int fd, char c)
{
 400:	83 ec 2c             	sub    $0x2c,%esp
 403:	88 54 24 1c          	mov    %dl,0x1c(%esp)
  write(fd, &c, 1);
 407:	8d 54 24 1c          	lea    0x1c(%esp),%edx
 40b:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
 412:	00 
 413:	89 54 24 04          	mov    %edx,0x4(%esp)
 417:	89 04 24             	mov    %eax,(%esp)
 41a:	e8 65 ff ff ff       	call   384 <write>
}
 41f:	83 c4 2c             	add    $0x2c,%esp
 422:	c3                   	ret    
 423:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
 429:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000430 <printint>:

static void
printint(int fd, int xx, int base, int sgn)
{
 430:	57                   	push   %edi
 431:	56                   	push   %esi
 432:	53                   	push   %ebx
 433:	89 c3                	mov    %eax,%ebx
 435:	83 ec 10             	sub    $0x10,%esp
  char buf[16];
  int i, neg;
  uint x;

  neg = 0;
  if(sgn && xx < 0){
 438:	8b 44 24 20          	mov    0x20(%esp),%eax
 43c:	85 c0                	test   %eax,%eax
 43e:	74 60                	je     4a0 <printint+0x70>
 440:	89 d0                	mov    %edx,%eax
 442:	c1 e8 1f             	shr    $0x1f,%eax
 445:	84 c0                	test   %al,%al
 447:	74 57                	je     4a0 <printint+0x70>
    neg = 1;
    x = -xx;
 449:	89 d0                	mov    %edx,%eax
  int i, neg;
  uint x;

  neg = 0;
  if(sgn && xx < 0){
    neg = 1;
 44b:	bf 01 00 00 00       	mov    $0x1,%edi
    x = -xx;
 450:	f7 d8                	neg    %eax
  } else {
    x = xx;
  }

  i = 0;
 452:	31 f6                	xor    %esi,%esi
 454:	eb 04                	jmp    45a <printint+0x2a>
 456:	66 90                	xchg   %ax,%ax
  do{
    buf[i++] = digits[x % base];
 458:	89 d6                	mov    %edx,%esi
 45a:	31 d2                	xor    %edx,%edx
 45c:	f7 f1                	div    %ecx
 45e:	0f b6 92 a3 07 00 00 	movzbl 0x7a3(%edx),%edx
  }while((x /= base) != 0);
 465:	85 c0                	test   %eax,%eax
    x = xx;
  }

  i = 0;
  do{
    buf[i++] = digits[x % base];
 467:	88 14 34             	mov    %dl,(%esp,%esi,1)
 46a:	8d 56 01             	lea    0x1(%esi),%edx
  }while((x /= base) != 0);
 46d:	75 e9                	jne    458 <printint+0x28>
  if(neg)
 46f:	85 ff                	test   %edi,%edi
 471:	74 07                	je     47a <printint+0x4a>
    buf[i++] = '-';
 473:	c6 04 14 2d          	movb   $0x2d,(%esp,%edx,1)
 477:	8d 56 02             	lea    0x2(%esi),%edx

  while(--i >= 0)
 47a:	8d 72 ff             	lea    -0x1(%edx),%esi
 47d:	8d 76 00             	lea    0x0(%esi),%esi
    putc(fd, buf[i]);
 480:	0f be 14 34          	movsbl (%esp,%esi,1),%edx
 484:	89 d8                	mov    %ebx,%eax
    buf[i++] = digits[x % base];
  }while((x /= base) != 0);
  if(neg)
    buf[i++] = '-';

  while(--i >= 0)
 486:	83 ee 01             	sub    $0x1,%esi
    putc(fd, buf[i]);
 489:	e8 72 ff ff ff       	call   400 <putc>
    buf[i++] = digits[x % base];
  }while((x /= base) != 0);
  if(neg)
    buf[i++] = '-';

  while(--i >= 0)
 48e:	83 fe ff             	cmp    $0xffffffff,%esi
 491:	75 ed                	jne    480 <printint+0x50>
    putc(fd, buf[i]);
}
 493:	83 c4 10             	add    $0x10,%esp
 496:	5b                   	pop    %ebx
 497:	5e                   	pop    %esi
 498:	5f                   	pop    %edi
 499:	c3                   	ret    
 49a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  neg = 0;
  if(sgn && xx < 0){
    neg = 1;
    x = -xx;
  } else {
    x = xx;
 4a0:	89 d0                	mov    %edx,%eax
  static char digits[] = "0123456789ABCDEF";
  char buf[16];
  int i, neg;
  uint x;

  neg = 0;
 4a2:	31 ff                	xor    %edi,%edi
 4a4:	eb ac                	jmp    452 <printint+0x22>
 4a6:	8d 76 00             	lea    0x0(%esi),%esi
 4a9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

000004b0 <printf>:
}

// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
 4b0:	55                   	push   %ebp
 4b1:	57                   	push   %edi
 4b2:	56                   	push   %esi
 4b3:	53                   	push   %ebx
 4b4:	83 ec 2c             	sub    $0x2c,%esp
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
 4b7:	8b 5c 24 44          	mov    0x44(%esp),%ebx
}

// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
 4bb:	8b 6c 24 40          	mov    0x40(%esp),%ebp
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
 4bf:	0f b6 0b             	movzbl (%ebx),%ecx
 4c2:	84 c9                	test   %cl,%cl
 4c4:	0f 84 86 00 00 00    	je     550 <printf+0xa0>
  char *s;
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
 4ca:	8d 44 24 48          	lea    0x48(%esp),%eax
{
  char *s;
  int c, i, state;
  uint *ap;

  state = 0;
 4ce:	31 f6                	xor    %esi,%esi
  ap = (uint*)(void*)&fmt + 1;
 4d0:	89 44 24 1c          	mov    %eax,0x1c(%esp)
 4d4:	eb 1b                	jmp    4f1 <printf+0x41>
 4d6:	66 90                	xchg   %ax,%ax
  for(i = 0; fmt[i]; i++){
    c = fmt[i] & 0xff;
    if(state == 0){
      if(c == '%'){
 4d8:	83 f9 25             	cmp    $0x25,%ecx
 4db:	74 7b                	je     558 <printf+0xa8>
        state = '%';
      } else {
        putc(fd, c);
 4dd:	0f be d1             	movsbl %cl,%edx
 4e0:	89 e8                	mov    %ebp,%eax
 4e2:	e8 19 ff ff ff       	call   400 <putc>
      } else if(c == '%'){
        putc(fd, c);
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
 4e7:	83 c3 01             	add    $0x1,%ebx
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
 4ea:	0f b6 0b             	movzbl (%ebx),%ecx
 4ed:	84 c9                	test   %cl,%cl
 4ef:	74 5f                	je     550 <printf+0xa0>
    c = fmt[i] & 0xff;
    if(state == 0){
 4f1:	85 f6                	test   %esi,%esi
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
    c = fmt[i] & 0xff;
 4f3:	0f b6 c9             	movzbl %cl,%ecx
    if(state == 0){
 4f6:	74 e0                	je     4d8 <printf+0x28>
      if(c == '%'){
        state = '%';
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
 4f8:	83 fe 25             	cmp    $0x25,%esi
 4fb:	75 ea                	jne    4e7 <printf+0x37>
      if(c == 'd'){
 4fd:	83 f9 64             	cmp    $0x64,%ecx
 500:	0f 84 ba 00 00 00    	je     5c0 <printf+0x110>
        printint(fd, *ap, 10, 1);
        ap++;
      } else if(c == 'x' || c == 'p'){
 506:	83 f9 70             	cmp    $0x70,%ecx
 509:	74 55                	je     560 <printf+0xb0>
 50b:	83 f9 78             	cmp    $0x78,%ecx
 50e:	66 90                	xchg   %ax,%ax
 510:	74 4e                	je     560 <printf+0xb0>
        printint(fd, *ap, 16, 0);
        ap++;
      } else if(c == 's'){
 512:	83 f9 73             	cmp    $0x73,%ecx
 515:	74 71                	je     588 <printf+0xd8>
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
 517:	83 f9 63             	cmp    $0x63,%ecx
 51a:	0f 84 c3 00 00 00    	je     5e3 <printf+0x133>
        putc(fd, *ap);
        ap++;
      } else if(c == '%'){
 520:	83 f9 25             	cmp    $0x25,%ecx
        putc(fd, c);
 523:	ba 25 00 00 00       	mov    $0x25,%edx
 528:	89 e8                	mov    %ebp,%eax
          s++;
        }
      } else if(c == 'c'){
        putc(fd, *ap);
        ap++;
      } else if(c == '%'){
 52a:	74 12                	je     53e <printf+0x8e>
        putc(fd, c);
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
 52c:	89 4c 24 18          	mov    %ecx,0x18(%esp)
 530:	e8 cb fe ff ff       	call   400 <putc>
        putc(fd, c);
 535:	8b 4c 24 18          	mov    0x18(%esp),%ecx
 539:	89 e8                	mov    %ebp,%eax
 53b:	0f be d1             	movsbl %cl,%edx
 53e:	e8 bd fe ff ff       	call   400 <putc>
      }
      state = 0;
 543:	31 f6                	xor    %esi,%esi
      } else if(c == '%'){
        putc(fd, c);
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
 545:	83 c3 01             	add    $0x1,%ebx
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
 548:	0f b6 0b             	movzbl (%ebx),%ecx
 54b:	84 c9                	test   %cl,%cl
 54d:	75 a2                	jne    4f1 <printf+0x41>
 54f:	90                   	nop
        putc(fd, c);
      }
      state = 0;
    }
  }
}
 550:	83 c4 2c             	add    $0x2c,%esp
 553:	5b                   	pop    %ebx
 554:	5e                   	pop    %esi
 555:	5f                   	pop    %edi
 556:	5d                   	pop    %ebp
 557:	c3                   	ret    
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
    c = fmt[i] & 0xff;
    if(state == 0){
      if(c == '%'){
        state = '%';
 558:	be 25 00 00 00       	mov    $0x25,%esi
 55d:	eb 88                	jmp    4e7 <printf+0x37>
 55f:	90                   	nop
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
        ap++;
      } else if(c == 'x' || c == 'p'){
        printint(fd, *ap, 16, 0);
 560:	8b 44 24 1c          	mov    0x1c(%esp),%eax
 564:	b9 10 00 00 00       	mov    $0x10,%ecx
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 569:	31 f6                	xor    %esi,%esi
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
        ap++;
      } else if(c == 'x' || c == 'p'){
        printint(fd, *ap, 16, 0);
 56b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
 572:	8b 10                	mov    (%eax),%edx
 574:	89 e8                	mov    %ebp,%eax
 576:	e8 b5 fe ff ff       	call   430 <printint>
        ap++;
 57b:	83 44 24 1c 04       	addl   $0x4,0x1c(%esp)
 580:	e9 62 ff ff ff       	jmp    4e7 <printf+0x37>
 585:	8d 76 00             	lea    0x0(%esi),%esi
      } else if(c == 's'){
        s = (char*)*ap;
 588:	8b 44 24 1c          	mov    0x1c(%esp),%eax
 58c:	8b 38                	mov    (%eax),%edi
        ap++;
 58e:	83 c0 04             	add    $0x4,%eax
 591:	89 44 24 1c          	mov    %eax,0x1c(%esp)
        if(s == 0)
 595:	85 ff                	test   %edi,%edi
 597:	74 64                	je     5fd <printf+0x14d>
          s = "(null)";
        while(*s != 0){
 599:	0f b6 17             	movzbl (%edi),%edx
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 59c:	31 f6                	xor    %esi,%esi
      } else if(c == 's'){
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
        while(*s != 0){
 59e:	84 d2                	test   %dl,%dl
 5a0:	0f 84 41 ff ff ff    	je     4e7 <printf+0x37>
 5a6:	66 90                	xchg   %ax,%ax
          putc(fd, *s);
 5a8:	0f be d2             	movsbl %dl,%edx
          s++;
 5ab:	83 c7 01             	add    $0x1,%edi
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
 5ae:	89 e8                	mov    %ebp,%eax
 5b0:	e8 4b fe ff ff       	call   400 <putc>
      } else if(c == 's'){
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
        while(*s != 0){
 5b5:	0f b6 17             	movzbl (%edi),%edx
 5b8:	84 d2                	test   %dl,%dl
 5ba:	75 ec                	jne    5a8 <printf+0xf8>
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 5bc:	31 f6                	xor    %esi,%esi
 5be:	eb 85                	jmp    545 <printf+0x95>
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
 5c0:	8b 44 24 1c          	mov    0x1c(%esp),%eax
 5c4:	b1 0a                	mov    $0xa,%cl
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 5c6:	66 31 f6             	xor    %si,%si
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
 5c9:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
 5d0:	8b 10                	mov    (%eax),%edx
 5d2:	89 e8                	mov    %ebp,%eax
 5d4:	e8 57 fe ff ff       	call   430 <printint>
        ap++;
 5d9:	83 44 24 1c 04       	addl   $0x4,0x1c(%esp)
 5de:	e9 04 ff ff ff       	jmp    4e7 <printf+0x37>
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
        putc(fd, *ap);
 5e3:	8b 44 24 1c          	mov    0x1c(%esp),%eax
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 5e7:	31 f6                	xor    %esi,%esi
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
        putc(fd, *ap);
 5e9:	0f be 10             	movsbl (%eax),%edx
 5ec:	89 e8                	mov    %ebp,%eax
 5ee:	e8 0d fe ff ff       	call   400 <putc>
        ap++;
 5f3:	83 44 24 1c 04       	addl   $0x4,0x1c(%esp)
 5f8:	e9 ea fe ff ff       	jmp    4e7 <printf+0x37>
        ap++;
      } else if(c == 's'){
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
 5fd:	bf 9c 07 00 00       	mov    $0x79c,%edi
 602:	eb 95                	jmp    599 <printf+0xe9>
 604:	90                   	nop
 605:	90                   	nop
 606:	90                   	nop
 607:	90                   	nop
 608:	90                   	nop
 609:	90                   	nop
 60a:	90                   	nop
 60b:	90                   	nop
 60c:	90                   	nop
 60d:	90                   	nop
 60e:	90                   	nop
 60f:	90                   	nop

00000610 <free>:
static Header base;
static Header *freep;

void
free(void *ap)
{
 610:	57                   	push   %edi
  Header *bp, *p;

  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 611:	a1 80 0a 00 00       	mov    0xa80,%eax
static Header base;
static Header *freep;

void
free(void *ap)
{
 616:	56                   	push   %esi
 617:	53                   	push   %ebx
 618:	8b 5c 24 10          	mov    0x10(%esp),%ebx
  Header *bp, *p;

  bp = (Header*) ap - 1;
 61c:	8d 4b f8             	lea    -0x8(%ebx),%ecx
 61f:	90                   	nop
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 620:	39 c8                	cmp    %ecx,%eax
 622:	8b 10                	mov    (%eax),%edx
 624:	73 04                	jae    62a <free+0x1a>
 626:	39 d1                	cmp    %edx,%ecx
 628:	72 16                	jb     640 <free+0x30>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
 62a:	39 d0                	cmp    %edx,%eax
 62c:	72 08                	jb     636 <free+0x26>
 62e:	39 c8                	cmp    %ecx,%eax
 630:	72 0e                	jb     640 <free+0x30>
 632:	39 d1                	cmp    %edx,%ecx
 634:	72 0a                	jb     640 <free+0x30>
static Header base;
static Header *freep;

void
free(void *ap)
{
 636:	89 d0                	mov    %edx,%eax
 638:	eb e6                	jmp    620 <free+0x10>
 63a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi

  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
 640:	8b 73 fc             	mov    -0x4(%ebx),%esi
 643:	8d 3c f1             	lea    (%ecx,%esi,8),%edi
 646:	39 d7                	cmp    %edx,%edi
 648:	74 18                	je     662 <free+0x52>
    bp->s.size += p->s.ptr->s.size;
    bp->s.ptr = p->s.ptr->s.ptr;
  } else
    bp->s.ptr = p->s.ptr;
 64a:	89 53 f8             	mov    %edx,-0x8(%ebx)
  if(p + p->s.size == bp){
 64d:	8b 50 04             	mov    0x4(%eax),%edx
 650:	8d 34 d0             	lea    (%eax,%edx,8),%esi
 653:	39 f1                	cmp    %esi,%ecx
 655:	74 22                	je     679 <free+0x69>
    p->s.size += bp->s.size;
    p->s.ptr = bp->s.ptr;
  } else
    p->s.ptr = bp;
 657:	89 08                	mov    %ecx,(%eax)
  freep = p;
 659:	a3 80 0a 00 00       	mov    %eax,0xa80
}
 65e:	5b                   	pop    %ebx
 65f:	5e                   	pop    %esi
 660:	5f                   	pop    %edi
 661:	c3                   	ret    
  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
    bp->s.size += p->s.ptr->s.size;
 662:	03 72 04             	add    0x4(%edx),%esi
 665:	89 73 fc             	mov    %esi,-0x4(%ebx)
    bp->s.ptr = p->s.ptr->s.ptr;
 668:	8b 10                	mov    (%eax),%edx
 66a:	8b 12                	mov    (%edx),%edx
 66c:	89 53 f8             	mov    %edx,-0x8(%ebx)
  } else
    bp->s.ptr = p->s.ptr;
  if(p + p->s.size == bp){
 66f:	8b 50 04             	mov    0x4(%eax),%edx
 672:	8d 34 d0             	lea    (%eax,%edx,8),%esi
 675:	39 f1                	cmp    %esi,%ecx
 677:	75 de                	jne    657 <free+0x47>
    p->s.size += bp->s.size;
 679:	03 53 fc             	add    -0x4(%ebx),%edx
    p->s.ptr = bp->s.ptr;
  } else
    p->s.ptr = bp;
  freep = p;
 67c:	a3 80 0a 00 00       	mov    %eax,0xa80
    bp->s.size += p->s.ptr->s.size;
    bp->s.ptr = p->s.ptr->s.ptr;
  } else
    bp->s.ptr = p->s.ptr;
  if(p + p->s.size == bp){
    p->s.size += bp->s.size;
 681:	89 50 04             	mov    %edx,0x4(%eax)
    p->s.ptr = bp->s.ptr;
 684:	8b 53 f8             	mov    -0x8(%ebx),%edx
 687:	89 10                	mov    %edx,(%eax)
  } else
    p->s.ptr = bp;
  freep = p;
}
 689:	5b                   	pop    %ebx
 68a:	5e                   	pop    %esi
 68b:	5f                   	pop    %edi
 68c:	c3                   	ret    
 68d:	8d 76 00             	lea    0x0(%esi),%esi

00000690 <malloc>:
  return freep;
}

void*
malloc(uint nbytes)
{
 690:	57                   	push   %edi
 691:	56                   	push   %esi
 692:	53                   	push   %ebx
 693:	83 ec 10             	sub    $0x10,%esp
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
 696:	8b 15 80 0a 00 00    	mov    0xa80,%edx
malloc(uint nbytes)
{
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
 69c:	8b 5c 24 20          	mov    0x20(%esp),%ebx
 6a0:	83 c3 07             	add    $0x7,%ebx
 6a3:	c1 eb 03             	shr    $0x3,%ebx
 6a6:	83 c3 01             	add    $0x1,%ebx
  if((prevp = freep) == 0){
 6a9:	85 d2                	test   %edx,%edx
 6ab:	0f 84 9d 00 00 00    	je     74e <malloc+0xbe>
 6b1:	8b 02                	mov    (%edx),%eax
 6b3:	8b 48 04             	mov    0x4(%eax),%ecx
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    if(p->s.size >= nunits){
 6b6:	39 d9                	cmp    %ebx,%ecx
 6b8:	73 6e                	jae    728 <malloc+0x98>
        p->s.size -= nunits;
        p += p->s.size;
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*) (p + 1);
 6ba:	8d 3c dd 00 00 00 00 	lea    0x0(,%ebx,8),%edi
 6c1:	eb 0e                	jmp    6d1 <malloc+0x41>
 6c3:	90                   	nop
 6c4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 6c8:	8b 02                	mov    (%edx),%eax
    if(p->s.size >= nunits){
 6ca:	8b 48 04             	mov    0x4(%eax),%ecx
 6cd:	39 cb                	cmp    %ecx,%ebx
 6cf:	76 57                	jbe    728 <malloc+0x98>
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*) (p + 1);
    }
    if(p == freep)
 6d1:	3b 05 80 0a 00 00    	cmp    0xa80,%eax
 6d7:	89 c2                	mov    %eax,%edx
 6d9:	75 ed                	jne    6c8 <malloc+0x38>
morecore(uint nu)
{
  char *p;
  Header *hp;

  if(nu < PAGE)
 6db:	81 fb ff 0f 00 00    	cmp    $0xfff,%ebx
 6e1:	b8 00 80 00 00       	mov    $0x8000,%eax
    nu = PAGE;
 6e6:	be 00 10 00 00       	mov    $0x1000,%esi
morecore(uint nu)
{
  char *p;
  Header *hp;

  if(nu < PAGE)
 6eb:	76 04                	jbe    6f1 <malloc+0x61>
 6ed:	89 f8                	mov    %edi,%eax
 6ef:	89 de                	mov    %ebx,%esi
    nu = PAGE;
  p = sbrk(nu * sizeof(Header));
 6f1:	89 04 24             	mov    %eax,(%esp)
 6f4:	e8 f3 fc ff ff       	call   3ec <sbrk>
  if(p == (char*) -1)
 6f9:	83 f8 ff             	cmp    $0xffffffff,%eax
 6fc:	74 1a                	je     718 <malloc+0x88>
    return 0;
  hp = (Header*)p;
  hp->s.size = nu;
 6fe:	89 70 04             	mov    %esi,0x4(%eax)
  free((void*)(hp + 1));
 701:	83 c0 08             	add    $0x8,%eax
 704:	89 04 24             	mov    %eax,(%esp)
 707:	e8 04 ff ff ff       	call   610 <free>
  return freep;
 70c:	8b 15 80 0a 00 00    	mov    0xa80,%edx
      }
      freep = prevp;
      return (void*) (p + 1);
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
 712:	85 d2                	test   %edx,%edx
 714:	75 b2                	jne    6c8 <malloc+0x38>
 716:	66 90                	xchg   %ax,%ax
        return 0;
  }
}
 718:	83 c4 10             	add    $0x10,%esp
      freep = prevp;
      return (void*) (p + 1);
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
        return 0;
 71b:	31 c0                	xor    %eax,%eax
  }
}
 71d:	5b                   	pop    %ebx
 71e:	5e                   	pop    %esi
 71f:	5f                   	pop    %edi
 720:	c3                   	ret    
 721:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    if(p->s.size >= nunits){
      if(p->s.size == nunits)
 728:	39 cb                	cmp    %ecx,%ebx
 72a:	74 1c                	je     748 <malloc+0xb8>
        prevp->s.ptr = p->s.ptr;
      else {
        p->s.size -= nunits;
 72c:	29 d9                	sub    %ebx,%ecx
 72e:	89 48 04             	mov    %ecx,0x4(%eax)
        p += p->s.size;
 731:	8d 04 c8             	lea    (%eax,%ecx,8),%eax
        p->s.size = nunits;
 734:	89 58 04             	mov    %ebx,0x4(%eax)
      }
      freep = prevp;
 737:	89 15 80 0a 00 00    	mov    %edx,0xa80
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
        return 0;
  }
}
 73d:	83 c4 10             	add    $0x10,%esp
        p->s.size -= nunits;
        p += p->s.size;
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*) (p + 1);
 740:	83 c0 08             	add    $0x8,%eax
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
        return 0;
  }
}
 743:	5b                   	pop    %ebx
 744:	5e                   	pop    %esi
 745:	5f                   	pop    %edi
 746:	c3                   	ret    
 747:	90                   	nop
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    if(p->s.size >= nunits){
      if(p->s.size == nunits)
        prevp->s.ptr = p->s.ptr;
 748:	8b 08                	mov    (%eax),%ecx
 74a:	89 0a                	mov    %ecx,(%edx)
 74c:	eb e9                	jmp    737 <malloc+0xa7>
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
 74e:	c7 05 80 0a 00 00 84 	movl   $0xa84,0xa80
 755:	0a 00 00 
    base.s.size = 0;
 758:	b8 84 0a 00 00       	mov    $0xa84,%eax
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
 75d:	c7 05 84 0a 00 00 84 	movl   $0xa84,0xa84
 764:	0a 00 00 
    base.s.size = 0;
 767:	c7 05 88 0a 00 00 00 	movl   $0x0,0xa88
 76e:	00 00 00 
 771:	e9 44 ff ff ff       	jmp    6ba <malloc+0x2a>
